<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/12/11
  Time: 9:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="js/calendarTime.js"></script>
</head>
<body>
    <center>
        <form action="getUserList.do" method="post">
            <input type="hidden" name="yema"/>
            按照用户名：<input type="text" name="uname" value="${requestScope.ub.uname}"/>--
            按照部门：<select name="db.deptid">
                        <option value="-1">--请选择--</option>
                        <c:forEach var="d" items="${dlist}">
                            <option value="${d.deptid}" ${ub.db.deptid==d.deptid?'selected':''}>${d.dname}</option>
                        </c:forEach>
                     </select><br>
            按照生日:<input type="text" name="sbirthday" readonly onclick="setDay(this)" value="<f:formatDate value='${sbirthday}' pattern='yyyy-MM-dd'></f:formatDate>"/>
            --至--<input type="text" name="ebirthday" readonly onclick="setDay(this)" value="<f:formatDate value='${ebirthday}' pattern='yyyy-MM-dd'></f:formatDate>"/>
            <input type="submit" value="检索"/>
        </form>
        <table border="1" rules="all">
            <tr align="center" bgcolor="#ffc0cb">
                <th>用户编号</th>
                <th>用户姓名</th>
                <th>年龄</th>
                <th>部门</th>
                <th>角色</th>
                <th>生日</th>
                <th colspan="100">操作<a href="toAddUser.do">新增</a></th>
            </tr>
            <c:forEach items="${list}" var="u">
                <tr align="center">
                    <td>${u.id}</td>
                    <td>${u.uname}</td>
                    <td>${u.age}</td>
                    <td>${u.db.dname}</td>
                    <td>${u.rb.rname}</td>
                    <td>
                        <f:formatDate value="${u.birthday}" pattern="yyyy-MM-dd"></f:formatDate>
                    </td>
                    <td><a href="deleteUserById.do?id=${u.id}"><button>删除</button></a></td>
                    <td><a href="toUpdateUser.do?id=${u.id}"><button>修改</button></a></td>
                    <td><a href="toUserDept.do?id=${u.id}"><button>分配部门</button></a></td>
                    <td><a href="toUserRole.do?id=${u.id}"><button>分配角色</button></a></td>
                    <td><button type="button" onclick="getUserPower(${u.id})">查看权限</button></td>
                </tr>
            </c:forEach>
            <tr align="center">
                <td colspan="100">
                    当前${page.currentPage}/${page.pageCount}页,共${page.count}条记录;
                    <input type="button" value="首页" onclick="paging(1)"/>
                    <input type="button" value="上一页" onclick="paging(${page.previousPage})"/>
                    <input type="button" value="下一页" onclick="paging(${page.nextPage})"/>
                    <input type="button" value="尾页" onclick="paging(${page.pageCount})"/>
                    跳转到:<input type="text" id="tz" value="${page.currentPage}" size="2">页<input type="button" value="go" onclick="paging('go')"/>
                </td>
            </tr>
        </table>

    </center>
</body>
<script>
    function paging(obj) {
        if(obj=='go'){
           obj =  document.getElementById("tz").value;
        }
        document.getElementsByName("yema")[0].value=obj;
        document.forms[0].submit();
    }
</script>
<script>
    function getUserPower(id) {
        window.open("getUserPower.do?id="+id,"","width=400px,height=500px");
    }
</script>
</html>
